package com.coship.acf;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

public abstract class CacheServer {	
	private Map<String, String> params = new HashMap<String, String>();
	
	private boolean active;
	
	public boolean isActive(){
		return active;
	}
	
	public boolean checkActive(){
		active = test();
		return active;
	}

	public void addParam(String name,String value) {
		this.params.put(name, value);
	}

	public String param(String name){
		return param(name, null);
	}
	
	public String param(String name,String defaultValue) {
		String param = this.params.get(name);
		return param == null ? defaultValue : param;
	}
	
	public int paramInt(String name,int defaultValue) {
		String param = param(name, defaultValue+"");
		return Integer.parseInt(param);
	}

	protected abstract boolean test();
	
	public abstract void init();

	public abstract void set(String key, Object value) throws Exception;

	public abstract void mset(List<Object> keyValues) throws Exception;

	public abstract Object get(String key) throws Exception;

	public abstract List<Object> mget(String... keys) throws Exception;

	public abstract void remove(String key) throws Exception;

	public abstract void clear() throws Exception;
	
	public abstract Set<String> keys(String pattern) throws Exception;
}